<?php

/**
 * Question form base class.
 *
 * @method Question getObject() Returns the current form's model object
 *
 * @package    iEasy
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseQuestionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                  => new sfWidgetFormInputHidden(),
      'create_time'         => new sfWidgetFormDateTime(),
      'update_time'         => new sfWidgetFormDateTime(),
      'content'             => new sfWidgetFormTextarea(),
      'user_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'add_empty' => true)),
      'ip'                  => new sfWidgetFormInputText(),
      'is_available'        => new sfWidgetFormInputCheckbox(),
      'is_on_top'           => new sfWidgetFormInputCheckbox(),
      'question_channel_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('QuestionChannel'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'                  => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'create_time'         => new sfValidatorDateTime(array('required' => false)),
      'update_time'         => new sfValidatorDateTime(array('required' => false)),
      'content'             => new sfValidatorString(array('max_length' => 500, 'required' => false)),
      'user_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'required' => false)),
      'ip'                  => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'is_available'        => new sfValidatorBoolean(array('required' => false)),
      'is_on_top'           => new sfValidatorBoolean(array('required' => false)),
      'question_channel_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('QuestionChannel'))),
    ));

    $this->widgetSchema->setNameFormat('question[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Question';
  }

}
